package com.gsafety.library.Widgets;

import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

import com.gsafety.library.Utils.DensityUtil;

/**
 * 沉浸模式下，可以弹出输入法所在的布局
 */
public class FullScreenLinearLayout extends LinearLayout
{

    public FullScreenLinearLayout(Context context)
    {
        this(context, null);
    }

    public FullScreenLinearLayout(Context context, @Nullable AttributeSet attrs)
    {
        this(context, attrs, 0);
    }

    public FullScreenLinearLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr)
    {
        super(context, attrs, defStyleAttr);
        setFitsSystemWindows(true);
    }


    @Override
    protected final boolean fitSystemWindows(Rect insets)
    {
        insets.top = 0;
        insets.left = 0;
        insets.right = 0;
        if (insets.bottom > 0)
        {
            insets.bottom -= DensityUtil.dip2px(getContext(), 0);
        }
        return super.fitSystemWindows(insets);
    }
}